const router = require('koa-router')()
const db = require('../model/db.js')
// 测试
// console.log('db', db);
// var mysql      = require('mysql');
// var connection = mysql.createConnection(db); 
// connection.connect();

router.prefix('/users')

router.get('/', function (ctx, next) {
  ctx.body = 'this is a users response!'
})

router.get('/bar', async function (ctx, next) {
  let res = await db.query('select * from user');
  console.log('数据库返回的信息/:', res);
  
  ctx.body = 'this is a users/bar response'
})

module.exports = router
